<template>
  <div>
    <img :src="userData.avatar" width="100" height="100">
    <p>姓名：{{ userData.uName }}</p>
    <p>年龄：{{ userData.age }}</p>
    <p>性别：{{ userData.sex }}</p>
    <p>部门：{{ userData.tName }}</p>
    <p>权限（职位）：{{ userData.power===0 ? '超管' : (userData.power===1 ? '经理' : '员工')}}</p>
    <p>注册时间：{{ new Date(userData.regTime).toLocaleString() }}</p>
  </div>
</template>

<script setup>
import { useUserStore } from '../../storesPinia/user';
import { getUser, getTeam } from '../../api';
import { reactive } from 'vue';

const userStore = useUserStore();

const userData = reactive({});

getUser({
  token: userStore.token,
  uId: userStore.uId
}).then(async res=>{
  if(res.data.code === 1){
    const data = res.data.data[0];
    console.log(data);
    userData.avatar = data.avatar;
    userData.uName = data.uName;
    userData.age = data.age
    userData.sex = data.sex
    userData.power = data.power
    userData.tel = data.tel
    userData.regTime = data.regTime
    const teamRes = await getTeam({
      token: userStore.token,
      tId: data.tId
    })
    userData.tName = teamRes.data.data[0].tName;

    console.log(userData);
  }
})



</script>